from flask import Flask
from app.config.config import Config
from app.routes import cookie_manage
from app.models import db


def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    db.init_app(app)
    app.register_blueprint(cookie_manage.API)

    @app.errorhandler(404)
    def page_not_found(e):
        return 'Page not found', 404

    @app.errorhandler(500)
    def internal_server_error(e):
        return 'Internal server error', 500

    return app